#define _CRT_SECURE_NO_WARNINGS 1
struct ListNode* middleNode(struct ListNode* head)
{
    int count = 0;
    struct ListNode* cur = head;
    while (cur)
    {
        count++;
        cur = cur->next;
    }
    if (count % 2 == 0)
    {
        int h = count / 2 + 1;
        h--;
        while (h)
        {
            head = head->next;
            h--;
        }
        return head;
    }
    else
    {
        int h = (count + 1) / 2;
        h--;
        while (h)
        {
            head = head->next;
            h--;
        }
        return head;
    }
}